package com.oocl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.pojo.DishType;
import com.oocl.service.DishTypeManager;
import com.oocl.service.factory.DishTypeManagerFactory;

@WebServlet("/sec/dishes/add")
public class AddDishServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private DishTypeManager dishTypeManager = DishTypeManagerFactory.getInstance();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<DishType> dishTypes = dishTypeManager.getAllDishTypes();
		request.setAttribute("dishTypes", dishTypes);
		
		request.getRequestDispatcher("/WEB-INF/views/add-dish.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
